<template>
  <div class="arder">
    <div class="headers">
      <div class="header-left">
        <van-dropdown-menu active-color="#1989fa">
          <van-dropdown-item
            v-model="searchs.type"
            :options="option1"
            @change="chan"
          />
        </van-dropdown-menu>
      </div>
      <div class="header-right" @click="$router.push('/channel/storeFilter')">
        <span class="polid"></span>
        <img src="@/assets/images/rader/filter.png" alt="" />
        <span>筛选</span>
      </div>
      <div
        class="header-right"
        @click="
          $router.push(
            '/channel/storeSearch',

          )
        "
      >
        <span class="polid"></span>
        <img src="@/assets/images/rader/search.png" alt="" />
        <span>搜索</span>
      </div>
    </div>
    <div class="card_list">
      <!-- <p>订单列表</p> -->
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <ul>
          <li v-for="(item, i) in list" :key="i">
            <h3>{{ item.tcName }}</h3>
            <div>
              <span>{{ item.shopName }}</span>
            </div>
            <div>
              <!-- <label>昨天：</label> -->
              <span>{{ item.orderTime }}</span>
            </div>
            <div
              class="list_right"
              @click="
                $router.push({
                  path: '/channel/storeDetail',
                  query: {
                    id: item.id,
                  },
                })
              "
            >
              <label>佣金</label>
              <span>{{ item.brokerage }}</span>
              <van-icon name="arrow" color="#999999" />
            </div>
          </li>
        </ul>
      </van-list>
    </div>
  </div>
</template>

<script>
import http from './service/service'
export default {
  name: 'storeArder',
  data () {
    return {
      searchs: {
        keyword: this.$store.state.teacher.keyword,
        type: 1,
        cityId: this.$store.state.teacher.filter.cityId || -1,
        countyId: this.$store.state.teacher.filter.countyId || -1,
        tcId: this.$store.state.teacher.filter.tcId || -1,
        startTime: this.$store.state.teacher.filter.starttime || '',
        endTime: this.$store.state.teacher.filter.endtime || '',
        pageNo: 1,
        pageSize: 10
      },
      loading: false,
      finished: false,
      option1: [
        { text: '门店', value: 1 },
        { text: '营业员', value: 2 }
        // { text: '个人', value: 3 }
      ],
      count: 0,
      list: []
    }
  },
  methods: {
    chan () {
      this.list = []
      this.finished = false
      this.searchs.pageNo = 1

      this.loading = true
      this.onLoad()
    },
    onLoad () {
      this.getlist()
    },
    getlist () {
      if (this.searchs.countyId.length === 4) {
        this.searchs.tcId = this.searchs.countyId.substring(0, 2)
      }
      http.getOrderNumListByPage(this.searchs).then((res) => {
        if (res.data.ret === 0) {
          this.list = this.list.concat(res.data.data.orderList)

          this.count = Math.ceil(res.data.data.totalCount / this.pageSize)
          if (this.list.length >= this.count) {
            this.finished = true
            return
          }
          this.onLoad()
          this.searchs.pageNo++
        } else {
          this.finished = true
          this.$toast.fail('网络错误')
        }
        this.loading = true
      })
    }
  }

}
</script>
<style lang="less" scoped>
.arder {
  .headers {
    background-color: #ffffff;
    margin-bottom: 10px;
    display: flex;
    .header-left {
      width: 46.7vw;
    }
    .header-right {
      display: flex;
      align-items: center;

      width: 26.6vw;
      font-size: 15px;
      img {
        margin-right: 8px;
      }
      .polid {
        width: 1px;
        height: 20px;
        background: #ebedf0;
        margin-right: 22px;
      }
    }
  }

  .card_list {
    padding: 0 15px;
    background: #fff;
    height: calc(100vh - 102px);
    overflow: auto;
    > p {
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 15px;
    }
    li {
      border-top: 1px solid #ebedf0;
      padding: 12px 0;
      position: relative;
      h3 {
        font-size: 15px;
      }
      div {
        margin-top: 8px;
        font-size: 12px;
        color: #999;
        // label {
        // }
        // span {
        // }
      }
      .list_right {
        margin: 0;
        font-size: 14px;
        color: #ff6565;
        position: absolute;
        top: 35px;
        right: 0;
      }
    }
  }
}
/deep/ .van-dropdown-menu__bar {
  box-shadow: none;
}
</style>
